<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";

%>
<html>
	<head>
		<base href="<%=basePath%>">
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"">
		<title>Insert title here</title>
	</head>
	<body>
		<div>
			<form action="" id="form1">
				用户名：
				<input name="userName" type="text">
				密码:
				<input name="passWord" type="password">
				&nbsp;验证码：
				<input id="validate" type="text">
				<img src="rand.action" onclick="changeValidateCode(this)" />
				<input name="" type="button" value="登陆" onclick="submitForm()"/>
			</form>
		</div>
	</body>
</html>
		<%	
		String rand = (String)session.getAttribute("rand");
			System.out.println("rand==============="+rand); %>
<script type="text/javascript">   
    function changeValidateCode(obj) {   
           //获取当前的时间作为参数，无具体意义   
        var timenow = new Date().getTime();   
           //每次请求需要一个不同的参数，否则可能会返回同样的验证码   
        //这和浏览器的缓存机制有关系，也可以把页面设置为不缓存，这样就不用这个参数了。   
        obj.src="rand.action?d="+timenow;   
    }   
    function checkVcode(vcode){
   		var bool = false;
		var txtvcode= <%=rand%>; 
		alert();
		//alert(txtvcode);
		if(vcode==txtvcode){
			alert("输入验证码正确");
			bool = true;
			alert(bool);
			return bool;
		}else{
			alert("输入验证码错误");
		} 
		return bool;
	}
	function submitForm(){
		var bool = checkVcode(document.getElementById("validate").value);
		alert("hui->"+bool);
		if(bool){
	
		}
	}
	
</script>



